#ifdef ECUT_MAIN

#include "TestRoadSegments.h"

CPPUNIT_TEST_SUITE_REGISTRATION(TestRoadSegments);


void TestRoadSegments::setUp()
{
	this->aRoad = new Road("Abbey Road");
	this->aSegment = new RoadSegment(this->aRoad, 100, 150, Intersection(1,2), Intersection(2,3));
}
void TestRoadSegments::testcontains() {
	CPPUNIT_ASSERT(aSegment->contains(100));
	CPPUNIT_ASSERT(aSegment->contains(125));
	CPPUNIT_ASSERT(aSegment->contains(150));
	CPPUNIT_ASSERT(!aSegment->contains(99));
	CPPUNIT_ASSERT(!aSegment->contains(151));
}

void TestRoadSegments::testoverlaps() {
	CPPUNIT_ASSERT(aSegment->overlaps(50, 101));
	CPPUNIT_ASSERT(aSegment->overlaps(101, 149));
	CPPUNIT_ASSERT(aSegment->overlaps(149, 200));
	CPPUNIT_ASSERT(aSegment->overlaps(100,150));
	CPPUNIT_ASSERT(aSegment->overlaps(99, 151));
	CPPUNIT_ASSERT(!aSegment->overlaps(50, 100));
	CPPUNIT_ASSERT(!aSegment->overlaps(150, 200));
}

void TestRoadSegments::testoverlapsExactly() {
	CPPUNIT_ASSERT(aSegment->overlapsExactly(100,150));
	CPPUNIT_ASSERT(!aSegment->overlapsExactly(100,151));
	CPPUNIT_ASSERT(!aSegment->overlapsExactly(101,150));
}
void TestRoadSegments::testaddEdge() {
	Vertex* oVertex = new Vertex("id1", 0.0, 0.0);
	Vertex* dVertex = new Vertex("id2", 0.0, 0.0);
	Edge* anEdge = new Edge("test", oVertex, dVertex);
	aSegment->addEdge(anEdge, false);
	util::LinkedList<Edge*>* lista = aSegment->getDecreasingEdges();
	CPPUNIT_ASSERT(lista->get(0)->equals(anEdge));
	delete anEdge;
	delete oVertex;
	delete dVertex;
}

void TestRoadSegments::tearDown() {
	delete aSegment;
}

#endif /* ECUT_MAIN */

